<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/15 0015
 * Time: 14:07
 */

namespace app\common\model;


use think\Model;

class Goods extends Model
{
    /*
     * 查询默认额度
     * */
    public function showDefont($defont = 1,$str = 0){
        $data = $this->query('select * from xb_goods where defont=:defont limit 1',['defont'=>$defont]);
        if ($str == 0){
            return !empty($data)?$data[0]['SalePrice']:1000;
        }else{
            return $data[0];
        }
    }

    /**
     * 获取所有上架中的产品
     *
     * @param string $field 选择字段|默认所有
     *
     * @return array
     */
    public function getAllGoods($field = '*')
    {
        return db('goods')->where(['IsShelves' => 1, 'Status' => 1])->field($field)->select();
    }
}